<template>
  <div class="comment-list" v-if="comments.length">
    <div v-for="comment in comments" :key="comment.id" class="comment-item">
      <div class="comment-content">
        <span class="username" @click="$emit('reply', comment.userId, comment.userInfo.nickName)">
          {{ comment.userInfo.nickName }}
        </span>
        <template v-if="comment.replyTo">
          <span class="reply-text">回复</span>
          <span class="username" @click="$emit('reply', comment.replyTo.userId, comment.replyTo.nickName)">
            {{ comment.replyTo.nickName }}
          </span>
        </template>
        <span class="text">：{{ comment.content }}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'CommentList',
  props: {
    comments: {
      type: Array,
      default: () => []
    }
  }
}
</script>

<style lang="scss" scoped>
.comment-list {
  margin-top: 12px;
  padding: 12px;
  background: #f8f8f8;
  border-radius: 8px;
  
  .comment-item {
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.6;
    
    &:last-child {
      margin-bottom: 0;
    }
    
    .comment-content {
      .username {
        color: #576b95;
        cursor: pointer;
        font-weight: 500;
        
        &:hover {
          opacity: 0.8;
        }
      }
      
      .reply-text {
        color: #999;
        margin: 0 4px;
      }
      
      .text {
        color: #333;
        word-break: break-all;
      }
    }
  }
}
</style> 